package cn.wolfcode.wolf2w.business.service.impl;

import cn.wolfcode.wolf2w.api.domain.UserInfoSearch;
import cn.wolfcode.wolf2w.business.repository.UserInfoRepository;
import cn.wolfcode.wolf2w.business.service.IUserInfoSearchService;
import cn.wolfcode.wolf2w.member.api.RemoteUserInfoService;
import cn.wolfcode.wolf2w.member.api.domain.UserInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 浪兎兎
 * @since 2025-06-12 15:17
 */
@Service
public class UserInfoSearchServiceImpl implements IUserInfoSearchService {
    @Autowired
    private RemoteUserInfoService userInfoService;
    @Autowired
    private UserInfoRepository userInfoRepository;
    @Override
    public void initSearch() {
        List<UserInfo> result = userInfoService.list("inner").getData();
        result.forEach(userInfo -> {
            UserInfoSearch userInfoSearch = new UserInfoSearch();
            BeanUtils.copyProperties(userInfo, userInfoSearch);
            userInfoRepository.save(userInfoSearch);
        });
    }
}
